<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('租房申请列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>申请人：</label>
                                <input type="text" name="sysUser.userName"/>
                            </li>
                            <li>
                                <label>房屋名称：</label>
                                <input type="text" name="houHouse.name"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="admin:apply:remove">
                    <i class="fa fa-remove"></i> 撤销
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('admin:apply:edit')}]];
        var removeFlag = [[${@permission.hasPermi('admin:apply:remove')}]];
        var prefix = ctx + "admin/apply";

        $(function() {
            var options = {
                url: prefix + "/listWithDetail/1",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "租房申请",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'applyId',
                    title: '租房申请唯一标识',
                    visible: false
                },
                {
                    field: 'houHouse.name',
                    title: '房屋名称'
                },
                {
                    field: 'sysUser.userName',
                    title: '申请人'
                },
                {
                    field: 'time',
                    title: '申请开始时间'
                },
                {
                    field: 'month',
                    title: '申请月数',
                    align: "center"
                },
                {
                    field: 'status',
                    title: '审批状态',
                    formatter: function (value, row, index) {
                        if (row.status == 1) {
                            return '<strong>等待审批</strong>';
                        } else if (row.status == 2) {
                            return '<strong>申请成功</strong>';
                        } else if (row.status == 3) {
                            return '<strong>申请失败</strong>';
                        }
                    },
                    cellStyle: function (value, row, index) {
                        if (row.status == 1) {
                            return {
                                css: {
                                    'color': '#565956'
                                }
                            };
                        } else if (row.status == 2) {
                            return {
                                css: {
                                    'color': '#088604'
                                }
                            };
                        } else if (row.status == 3) {
                            return {
                                css: {
                                    'color': '#ce0606'
                                }
                            };
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.status == 1){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.applyId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.applyId + '\')"><i class="fa fa-remove"></i>撤销</a>');
                        }
                      return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>